﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using InfoTech.LanTranh.MucVu.Bussiness;

namespace GiaoXuLanTranh_MucVu.Reports.BiTich
{
    public partial class ChungNhanBiTich1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                IEnumerable<LINHMUC> enumerable = InfoTech.Core.Data.Receiver.TypeObject<LINHMUC>.SelectMany();
                var query =
                    enumerable.OrderBy(c => c.TEN).ThenBy(c => c.HOVATENDEM).ThenBy(c => c.TENTHANH).Select(
                        c =>
                        new
                            {
                                c.MACHAXU,
                                TENLINHMUC =
                            (c.PRT_LINHMUC_CHUCVU.IsPersistence ? c.PRT_LINHMUC_CHUCVU.TENCHUCVU + " " : "") +
                            c.GetFullName()
                            });
                DropDownList1.DataSource = query;
                DropDownList1.DataTextField = "TENLINHMUC";
                DropDownList1.DataValueField = "MACHAXU";
                DropDownList1.DataBind();
                DropDownList2.DataSource = query;
                DropDownList2.DataTextField = "TENLINHMUC";
                DropDownList2.DataValueField = "MACHAXU";
                DropDownList2.DataBind();
            }
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            string url;
            if ("ruatoi".Equals(Request.QueryString["type"], StringComparison.CurrentCultureIgnoreCase))
                url = "RuaToi.aspx";
            else if ("ruocle".Equals(Request.QueryString["type"], StringComparison.CurrentCultureIgnoreCase))
                url = "RuocLe.aspx";
            else if ("themsuc".Equals(Request.QueryString["type"], StringComparison.CurrentCultureIgnoreCase))
                url = "ThemSuc.aspx";
            else
                url = "ChungThuBiTich.aspx";
            string machaxu = DropDownList1.SelectedValue;
            string machadaidien = DropDownList2.SelectedValue;
            string giaodan = Request.QueryString["id"];
            Response.Redirect(string.Format("{0}?machaxu={1}&machadaidien={2}&id={3}", url, machaxu, machadaidien, giaodan));
        }
    }
}
